<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">产品代码</label>
        <el-input v-model="query.booksetId" clearable placeholder="产品代码" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">产品名称</label>
        <el-input v-model="query.booksetName" clearable placeholder="产品名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-date-picker
          v-model="query.valDate"
          :default-time="['00:00:00','23:59:59']"
          type="daterange"
          range-separator=":"
          size="small"
          class="date-item"
          start-placeholder="valDateStart"
          end-placeholder="valDateEnd"
        />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="流水号">
            <el-input v-model="form.seqNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品代码">
            <el-input v-model="form.booksetId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品名称">
            <el-input v-model="form.booksetName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收益类型">
            <el-input v-model="form.profitType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="估值日期">
            <el-input v-model="form.valDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="明细区分">
            <el-input v-model="form.detailDist" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="科目号">
            <el-input v-model="form.subjetNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="科目名称">
            <el-input v-model="form.subjectName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="上级科目号">
            <el-input v-model="form.fsubjectId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="数量">
            <el-input v-model="form.numAmt" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="单位成本">
            <el-input v-model="form.unitCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="cost">
            <el-input v-model="form.cost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="本币成本占比">
            <el-input v-model="form.costPercent" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="原币市值">
            <el-input v-model="form.marketValue" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="本币市值占比">
            <el-input v-model="form.valuePercent" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="本币市值占比">
            <el-input v-model="form.valueIncrement" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="balFlag">
            <el-input v-model="form.balFlag" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="影子价格估值">
            <el-input v-model="form.shadowPriceValue" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建人">
            <el-input v-model="form.createUser" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建部门">
            <el-input v-model="form.createDept" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建时间">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新人">
            <el-input v-model="form.updateUser" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新时间">
            <el-input v-model="form.updateTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="行情日期">
            <el-input v-model="form.marketValDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="分层代码">
            <el-input v-model="form.layeringId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="行情">
            <el-input v-model="form.closePrice" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="seqNo" label="流水号" />
        <el-table-column prop="booksetId" label="产品代码" />
        <el-table-column prop="booksetName" label="产品名称" />
        <el-table-column prop="profitType" label="收益类型" />
        <el-table-column prop="valDate" label="估值日期">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.valDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="detailDist" label="明细区分" />
        <el-table-column prop="subjetNo" label="科目号" />
        <el-table-column prop="subjectName" label="科目名称" />
        <el-table-column prop="fsubjectId" label="上级科目号" />
        <el-table-column prop="numAmt" label="数量" />
        <el-table-column prop="unitCost" label="单位成本" />
        <el-table-column prop="cost" label="cost" />
        <el-table-column prop="costPercent" label="本币成本占比" />
        <el-table-column prop="marketValue" label="原币市值" />
        <el-table-column prop="valuePercent" label="本币市值占比" />
        <el-table-column prop="valueIncrement" label="本币市值占比" />
        <el-table-column prop="balFlag" label="balFlag" />
        <el-table-column prop="shadowPriceValue" label="影子价格估值" />
        <el-table-column prop="createUser" label="创建人" />
        <el-table-column prop="createDept" label="创建部门" />
        <el-table-column prop="createTime" label="创建时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="updateUser" label="更新人" />
        <el-table-column prop="updateTime" label="更新时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="marketValDate" label="行情日期">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.marketValDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="layeringId" label="分层代码" />
        <el-table-column prop="closePrice" label="行情" />
        <el-table-column v-permission="['admin','bookValue:edit','bookValue:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudBookValue from '@/api/biz/bookValue'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultCrud = CRUD({ title: 'BokValue', url: 'api/biz/bookValue', idField: 'seqNo', sort: 'seqNo,desc', crudMethod: { ...crudBookValue }})
const defaultForm = { seqNo: null, booksetId: null, booksetName: null, profitType: null, valDate: null, detailDist: null, subjetNo: null, subjectName: null, fsubjectId: null, numAmt: null, unitCost: null, cost: null, costPercent: null, marketValue: null, valuePercent: null, valueIncrement: null, balFlag: null, shadowPriceValue: null, createUser: null, createDept: null, createTime: null, updateUser: null, updateTime: null, marketValDate: null, layeringId: null, closePrice: null }
export default {
  name: 'BookValue',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  data() {
    return {
      permission: {
        add: ['admin', 'bookValue:add'],
        edit: ['admin', 'bookValue:edit'],
        del: ['admin', 'bookValue:del']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'booksetId', display_name: '产品代码' },
        { key: 'booksetName', display_name: '产品名称' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
